﻿namespace UserManagement.Dal
{
    /// <summary>
    /// The Unit of work base contract
    /// </summary>
    public interface IUnitOfWork
    {
       /// <summary>
        /// Adds the specified item.
        /// </summary>
        /// <typeparam name="T">the type of item</typeparam>
        /// <param name="entity">The item we want to add.</param>
        /// <returns>The new entity just added to the system</returns>
        T Add<T>(T entity) where T : class;

        /// <summary>
        /// Deletes the specified item.
        /// </summary>
        /// <typeparam name="T">the type of the item to be deleted</typeparam>
        /// <param name="entity">The entity which will be deleted.</param>
        void Delete<T>(T entity) where T : class;

        /// <summary>
        /// Updates the specified item.
        /// </summary>
        /// <typeparam name="T">the type of the item to update</typeparam>
        /// <param name="entity">The entity we want to update.</param>
        void Update<T>(T entity) where T : class;

        /// <summary>
        /// create a new specified entity.
        /// </summary>
        /// <typeparam name="T">type of the entity we want to create.</typeparam>
        /// <param name="entity">Entity to be created.</param>
        /// <param name="entityDataName">Data source Name of the entity.</param>
        /// <param name="overwriteCurrentDataSource">if we want the system overwrite the existed same data source,
        /// set it to true, otherwise false</param>
        void Create<T>(T entity, string entityDataName, bool overwriteCurrentDataSource = false) where T : class;

        /// <summary>
        /// Begins the transaction.
        /// </summary>
        void BeginTransaction();

         /// <summary>
         /// Commits the transaction.
         /// </summary>
        void CommitTransaction();

        /// <summary>
        /// Rollbacks the transaction.
        /// </summary>
        void RollbackTransaction();
    }
}